;(function() {
  var Event = new Vue();

  Vue.component('btn', {
    template: '#btn_component',
    data: function() {
      return {
        isToggle: false,
        src: '../images/下拉按钮.png',
        text: '点击查看宝贝',
      }
    },
    methods: {
      toggle_item: function() {
        if (!this.isToggle) {
          this.src = '../images/收起按钮.png';
          this.text = '点击收起';
        }
        else {
          this.src = '../images/下拉按钮.png';
          this.text = '点击查看宝贝';
        }
        this.isToggle = !this.isToggle;
        Event.$emit('show_item');
      },
    }
  });

  Vue.component('item', {
    template: '#item_component',
    data: function() {
      return {
        show: false,
      }
    },
    mounted: function() {
      var me = this;
      Event.$on('show_item', function() {
        me.show = !me.show;
      });
    }
  })

  new Vue({
    el: '#app',
  });
})();
